import 'package:flutter/material.dart';
import 'package:startup_namer/pages/index_page.dart';
import 'package:startup_namer/provide/category_goods_list.dart';
import 'package:startup_namer/provide/currentIndex.dart';
import 'provide/details_info.dart';
import 'package:startup_namer/provide/counter.dart';
import 'package:provide/provide.dart';
import 'package:startup_namer/provide/child_category.dart';
import 'package:fluro/fluro.dart';
import 'package:startup_namer/routers/routers.dart';
import 'package:startup_namer/routers/application.dart';
import './provide/cart.dart';

void main() {

  var counter = Counter();
  var childCategory = ChildCategory();
  var providers = Providers();
  var categoryGoodsListProvide= CategoryGoodsListProvide();
  var detailsInfoProvide = DetailsInfoProvide();
  var cartProvide = CartProvide();
  var currentIndexProvide  = CurrentIndexProvide();

  providers
    ..provide(Provider<Counter>.value(counter))
    ..provide(Provider<CategoryGoodsListProvide>.value(categoryGoodsListProvide))
    ..provide(Provider<DetailsInfoProvide>.value(detailsInfoProvide))
    ..provide(Provider<CartProvide>.value(cartProvide))
    ..provide(Provider<CurrentIndexProvide>.value(currentIndexProvide))
    ..provide(Provider<ChildCategory>.value(childCategory));

  runApp(ProviderNode(child: MyAPP(), providers: providers));
}

class MyAPP extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    final router = Router();
    Routes.configureRoutes(router);
    Application.router = router;

    return Container(
      child: MaterialApp(
        title: "百姓生活+",
        onGenerateRoute: Application.router.generator,
        debugShowCheckedModeBanner: false,
        theme: ThemeData(primaryColor: Colors.pink),
        home: IndexPage(),
      ),
    );
  }
}
